package com.d3works.apps.account.service.fixedasset;

import com.d3works.apps.account.db.FixedAsset;
import com.d3works.apps.account.db.FixedAssetLine;
import com.d3works.exception.D3worksException;
import java.math.BigDecimal;
import java.util.List;
import java.util.Optional;

/** This service is used to compute new lines from an existing fixed asset header. */
public interface FixedAssetLineComputationService {

  /**
   * Compute the first fixed asset line from an empty fixed asset.
   *
   * @param fixedAsset a fixed asset with no lines
   * @param typeSelect typeSelect of the fixedAssetLine
   * @return the created fixed asset line
   * @throws D3worksException
   */
  Optional<FixedAssetLine> computeInitialPlannedFixedAssetLine(FixedAsset fixedAsset)
      throws D3worksException;

  /**
   * Compute the next fixed asset line from a fixed asset and the previous line.
   *
   * @param fixedAsset a fixed asset with existing lines
   * @param previousFixedAssetLine the previous line
   * @param typeSelect typeSelect of the fixedAssetLine
   * @return the created fixed asset line
   * @throws D3worksException
   */
  FixedAssetLine computePlannedFixedAssetLine(
      FixedAsset fixedAsset, FixedAssetLine previousFixedAssetLine) throws D3worksException;

  /**
   * Multiply line by prorata
   *
   * @param line
   * @param prorata
   */
  void multiplyLineBy(FixedAssetLine line, BigDecimal prorata);

  /**
   * Multiply economic and fiscal lines by prorata
   *
   * @param line
   * @param prorata
   */
  void multiplyLinesBy(List<FixedAssetLine> fixedAssetLineList, BigDecimal prorata);
}
